Skip to Main Content
JavaScript 深入精要
book

JavaScript 深入精要

by Cody Lindley
December 2013
Intermediate to advanced content levelIntermediate to advanced
160 pages
2h 41m
Chinese
GoTop Information, Inc.
Content preview from JavaScript 深入精要
JavaScript 物件
   
11
// log/驗證哪一個建構式建立了物件
console.log(myNumber.constructor); // logs Number()
console.log(myString.constructor); // log String()
console.log(myBoolean.constructor); // log Boolean()
console.log(myObject.constructor); // log Object()
console.log(myArray.constructor); // 在現代瀏覽器 log Array()
console.log(myFunction.constructor); // log Function()
console.log(myDate.constructor); // log Date()
console.log(myRegExp.constructor); // log RegExp()
console.log(myError.constructor); // log Error()
</script></body></html>
藉由
new
運算子,我們可以告訴 JavaScript 解譯器:我們想要一個物件,它是建構函式
的實例。例如,在上述的程式中,
Date()
建構函式建立了 date 物件。
Date()
建構函式是
date 物件的餅乾模具。也就是說,
Date()
建構函式會 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

JavaScript 設計模式

JavaScript 設計模式

Stoyan Stefanov
HTML5 錦囊妙計

HTML5 錦囊妙計

Christopher Schmitt, Kyle Simpson
jQuery Mobile建置與執行

jQuery Mobile建置與執行

Maximiliano Firtman

Publisher Resources

ISBN: 9789863470120