Laravel  
laravel
文档
数据库
架构
入门
php技术
    
Laravelphp
laravel / php / java / vue / mysql / linux / python / javascript / html / css / c++ / c#

javascript 数据类型

作者:__龙泉丶聂风   发布日期:2025-10-05   浏览:65

// JavaScript 数据类型示例

// 1. 基本数据类型(Primitive Types)
// 1.1 数值型(Number)
let num = 42;
console.log(typeof num); // "number"

// 1.2 字符串型(String)
let str = "Hello, world!";
console.log(typeof str); // "string"

// 1.3 布尔型(Boolean)
let bool = true;
console.log(typeof bool); // "boolean"

// 1.4 空值(Null)
let nullValue = null;
console.log(typeof nullValue); // "object" (这是一个历史遗留问题,实际上null表示空值)

// 1.5 未定义(Undefined)
let undefinedValue;
console.log(typeof undefinedValue); // "undefined"

// 1.6 符号型(Symbol)(ES6 引入)
let sym = Symbol('description');
console.log(typeof sym); // "symbol"

// 2. 复杂数据类型(Complex Types)
// 2.1 对象(Object)
let obj = { key: "value" };
console.log(typeof obj); // "object"

// 2.2 数组(Array)
let arr = [1, 2, 3];
console.log(typeof arr); // "object" (数组在JavaScript中也是对象)

// 2.3 函数(Function)
function myFunction() {}
console.log(typeof myFunction); // "function" (函数在JavaScript中是一级公民,属于对象的一种)

// 2.4 BigInt (ES2020 引入)
let bigInt = 1234567890123456789012345678901234567890n;
console.log(typeof bigInt); // "bigint"

上一篇:javascript console

下一篇:js innerhtml

大家都在看

js 数组对象排序

js 数组删掉第一个值

js fill

js 数组连接

js json数组

js 数组复制

js 复制数组

js 数组拷贝

js 对象数组合并

js 对象转数组

Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3

Laravel 中文站