基本包裝型別就是把簡單資料型別包裝為復雜資料型別,
var str = 'andy';
console.log(str.length);
物件和復雜資料型別才有屬性和方法,為什么這里會有length屬性呢?
程序為:
var temp = new String('andy'); //包裝為復雜資料型別
str = temp; //把臨時變數的值給str
temp = null; //會自動銷毀這個臨時變數
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/146038.html
標籤:其他
上一篇:基本包裝型別
