ãã¡ãããå ã« Firefox ã§ãã試ãã¦ãªãã¨ç½ç¶ãã¦ããã¾ãã
JavaScript ã¯æ°å¤ããªãã¸ã§ã¯ãã®ããã«æ±ãã
(1).toString() // æåå "1" ã復帰ããã
ãããã以ä¸ã®ã³ã¼ãã試ãã¨
var a = 1; n.a = 1; alert(n.a); // undefined ã¨è¡¨ç¤ºããã
ããã§äºã¤ä»®èª¬ãç«ã¦ã
- æ°å¤ã¸ã®ããããã£è¿½å ã¯ã¹ã«ã¼ãããã
- æ°å¤ã¯ãããæ¼ç®ã«ãã£ã¦ä¸æçã«ãªãã¸ã§ã¯ãåããã¦ãã®å¾æ»ããã ããããªãã¸ã§ã¯ãåãããã¨ãã«ä»£å ¥ããã¦ããåã³ãªãã¸ã§ã¯ãåãããã¨ãã¨ã¯å¥ã®ãªãã¸ã§ã¯ãã«ãªã£ã¦ããã
ã©ãããã°ãããã確ãããããã ããã
ããããæ©ãã (æ·±å¤4æ)ãããããã¼ãããã¼ãã
æãã¤ããï¼
ããããã°ããããããï¼
alert(typeof 1); // 'numer' (function(){alert(typeof this)}).apply(1); // 'object'
æåï¼ããã§è¨¼æã§ããï¼
ããé¢æ°ãã1ãã®ã¡ã½ããã¨ãã¦å¼ãã ã¨ãã1ãã¯ãªãã¸ã§ã¯ãã«ãªã£ã¦ããã®ã ãããããåã®çµæããæ¨æ¸¬ããã¨ä¸æçã«ãªãã¸ã§ã¯ãã«ãªããæ°å¤ã«æ»ããããã«ã¾ãå¿
è¦ãªã¨ãã¯å¥ã®æ°ãããªãã¸ã§ã¯ãã«ãªãã
ã¨ãããã¨ã¯
var n = 1; n.toString();
ããã®ç価å¼ã¯
var n = 1; (new Number(n)).toString();
ã¨ãããã¨ã«ãªãã
ã¡ãªã¿ã«
æååã¨çå½å¤ã«ãåããã¨ãè¨ãã¾ãã
以ä¸ãç価å¼ã«ãªãã¨ãããã¨ã
var a = "1234"; a.charAt(1); a.charAt(2); a.charAt(3);
var a = "1234"; (new String(a)).charAt(1); (new String(a)).charAt(2); (new String(a)).charAt(3);
åè¡ã§ new ãããããæ°ãä»ããã
ãã®è¾ºãæèããã¨
ãããªãé«éåã®ã¢ã¤ãã¢ãçã¾ãããã ãªãã