獲取變數資料型別

2022-07-29 04:36:12 字數 601 閱讀 5453

獲取變數資料型別

1、獲取檢測變數的資料型別

typeof可用來獲取檢測變數的資料型別

var num=10;

console.log(

typeof num); //

number

var str='abc';

console.log(

typeof str); //

string

var flag=true

;console.log(

typeof flag); //

boolean

var vari=undefined;

console.log(

typeof vari); //

undefined

var timer=null

;console.log(

typeof timer); //

object

2、字面量

字面量是在源**中乙個固定值的表示法,通俗來說,就是字面量表示如何表達這個值

獲取變數資料型別的程式

delphi syntax function vartype const v variant tvartype vartype contents of variant varempty the variant is unassigned.varnull the variant is null.var...

JS學習之獲取變數資料型別

doctype html utf 8 獲取變數資料型別 title var num 109,str1 pink flag true console.log typeof num console.log typeof str1 console.log typeof flag console.log t...

變數 資料型別

記錄資料 每一次 的值可能會變,用變數抽象代指 數學變數 設x 求 y 3 x 10 1.變數的宣告及初始化 型別關鍵字 變數名 初始值 變數名 純字母 組合 非關鍵字 字母1.數字不能開頭 long x1 3 int x2 3 short x3 3 byte x4 127 x4 5 x4 x1 變...