js資料型別

2021-08-11 18:36:32 字數 540 閱讀 4323

function

show(x) ); //

function

console.log(

typeof [1, 'a', true]); //

object

console.log(typeof ); //

object

console.log(typeof

null); //

object

console.log(typeof

new number(10)); //

object

} show();

以上**列出了typeof輸出的集中型別標識,其中上面的四種(undefined, number, string, boolean)屬於簡單的

值型別,不是物件。剩下的幾種情況——函式、陣列、物件、null、new number(10)都是物件。他們都是

引用型別。

判斷乙個物件是不是變數非常簡單,值型別的判斷用typeof,引用型別的用instanceof

js資料型別

一.原始資料型別 1.typeof 運算子。var a alert typeof a 輸出結果為 undefined 2.undefined 未定義 型別 當變數未定義時,該變數值被預設為undefined 如 var a alert typeof a 輸出結果為 undefined 注意值unde...

js資料型別

js 基本資料型別 undefined null boolean number string js 操作符 typeof檢測給定變數的資料型別。返回值表示的型別 undefined 值未定義。boolean 值為布林型別。string 值為字串。number 值為數字。object 值為物件或nul...

js資料型別

var num 1,boo true,aa null,bb,str mary arr 1,2,4,8 obj arrnew new array 1,2,3 strnew new string 1,2,3 用 typeof 檢測變數的型別 console.log number typeof num n...