Web_Design 板


LINE

※ 引述《WJames (星晨)》之銘言: : 這不是作業,也不是 take home exam。 : 這是小弟在應徵工作時碰到的 JS考題。 : 免試早已經結束,只是當時有用手機將考題拍下來。 : 想說有機會可以上來跟強者討論討論,很想知道正確解答, : 跟我的作答差距多少,由於公司也沒告訴我正確答案(筆試),試卷他們收走 : 我也不好意思問,就post在版上,讓各位前輩強者有興趣的話回答一下囉。 : 也算是分享應徵考試的經驗給大家。 : 1. which is equl to the condition : if( ua !== 'IE 6'&& ua != 'IE 7') : A) if( ua === 'IE 6' || ua === 'IE 7') : B) if( ua === 'IE 6' && ua === 'IE 7') : C) if( !( ua === 'IE 6'|| ua === 'IE 7') ) : D) if( !( ua === 'IE 6'&& ua === 'IE 7') ) C 這題要先從 statement 的反面下手 不等於 改成 等於 且 改成 或 用中文解釋的話就是 ua不是IE6且ua不是IE7 的反面是 ua是IE6或ua是IE7 最後再否定他 就是否定的否定=肯定 這個好像叫做 迪摩根定理 : 2. Which is false ? : A) 1 == '1' : B) NaN == NaN : C) 1 == [1]+[] : D) undefind === undefined B 老梗題目了... 不過這題的 C 我還是搞不懂怎麼解釋他 : 3. Which is true ? : A) 1=== true : B) Number('1px') : C) typrof [1,2,3] == 'array' : D) '0' D 在判斷真假的時候 字串會被轉為ascii字碼 '0'會被轉換成30 大於0所以為真 : 4. What is b : : var a = [ 1, 2, 3 ]; : var b = a; : a.push(5); : console.log(b) [1,2,3,5] object 與 array 都是傳址 array 可以呼叫 .slice(0) 進行複製 object 要透過迴圈 : 5. Please answer below two "this"? : $('#foo').on('click', function(e){ : console.log( this ); //What is this ? native DOM node #foo : setTimeout( function(){ : console.log( this ); //What is this ? 全域物件window : }, 1000} : }) 這題要講解有點困難... 可以跳過嗎QQ? http://rettamkrad.blogspot.tw/2012/11/how-this-works-in-javascript.html : 6. How can get the 'hello': : var obj = { 1: 'hello', 2: 'world'} : A) obj.1 : B) obj[0] : C) obj[1] : D) obj.2 C 這題應該不用說明吧 A 與 D 會發生例外 syntax error: unexpected number : 7.Please answer all below typeof: : typeof function(){} 'function' : typeof new Date() 'object' : typeof {} 'object' : typeof new Array() 'object' 我的記法是除了基本資料型態以外都是回傳 'object' function 會回傳 'function' 還有個例外是 undefined 會回傳 'undefined' 但是 null 會回傳 'object' 是個很大的陷阱 不亞於 array 回傳 'object' : 8.What do you think foo() is ? : if(1) function foo(){ return 'a'} : else function foo(){ return 'b'} : console.log( foo() ) 'b' function declaration vs expression http://tinyurl.com/34b4udr http://tinyurl.com/kzs7yd9 : 9.What is the console.log output? : function foo(){ : return this; : } : console.log( foo.call( foo ) ) function foo() { 略 } http://dreamerslab.com/blog/tw/javascript-call-and-apply/ : 10.Please explain what is the difference between "setTimeout()" and : "setInterval()" ? 一個是只執行一次 另一個是重複執行 : 11.Please explain what the use of "preventDefault()" and ""stopPropagation()" : in Event Object ? preventDefault 是取消 event 的預設行為 像是對 <a> click 會造成換頁、<input type="submit">會送出表單之類 stopPropagation()是阻止事件向更上層的元素傳播 像是巢狀的 div 標籤 <div id="first"> <div id="second"> <div id="third">Click me!</div> </div> </div> 對 div#third, #second, #first 監聽 click 事件 並在 #second 的 handler 使用 event.stopPropagation() 的話 就不會觸發 #first 的 click 事件 http://jsfiddle.net/KwtP7/ : 以上 就這幾題 : 至於是哪家公司的面試題目 我就不透漏了,透露出來好像不太好 --
1F:推 jumbotest:反正操妳妹應該只是基本作 她開心就好 01/21 15:40
2F:→ jumbotest: 操01/21 15:40
3F:→ jumbotest:我沒有罵髒話01/21 15:44
--



※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 59.127.251.59
4F:推 WJames:感謝推...但是蠻想聽聽第五題的講解的...QQ 06/13 01:48
5F:→ WJames:或是有推薦什麼參考資料嗎? 我自己看 06/13 01:49
補上參考連結: http://rettamkrad.blogspot.tw/2012/11/how-this-works-in-javascript.html ※ 編輯: s25g5d4 來自: 59.127.251.59 (06/13 02:25) ※ 編輯: s25g5d4 來自: 59.127.251.59 (06/13 02:47)
6F:推 rettamkrad:object(array)遇到+號都是先轉成字串,所以變成'1'+'' 06/13 18:58
7F:推 applexva:推 06/15 10:11







like.gif 您可能會有興趣的文章
icon.png[問題/行為] 貓晚上進房間會不會有憋尿問題
icon.pngRe: [閒聊] 選了錯誤的女孩成為魔法少女 XDDDDDDDDDD
icon.png[正妹] 瑞典 一張
icon.png[心得] EMS高領長版毛衣.墨小樓MC1002
icon.png[分享] 丹龍隔熱紙GE55+33+22
icon.png[問題] 清洗洗衣機
icon.png[尋物] 窗台下的空間
icon.png[閒聊] 双極の女神1 木魔爵
icon.png[售車] 新竹 1997 march 1297cc 白色 四門
icon.png[討論] 能從照片感受到攝影者心情嗎
icon.png[狂賀] 賀賀賀賀 賀!島村卯月!總選舉NO.1
icon.png[難過] 羨慕白皮膚的女生
icon.png閱讀文章
icon.png[黑特]
icon.png[問題] SBK S1安裝於安全帽位置
icon.png[分享] 舊woo100絕版開箱!!
icon.pngRe: [無言] 關於小包衛生紙
icon.png[開箱] E5-2683V3 RX480Strix 快睿C1 簡單測試
icon.png[心得] 蒼の海賊龍 地獄 執行者16PT
icon.png[售車] 1999年Virage iO 1.8EXi
icon.png[心得] 挑戰33 LV10 獅子座pt solo
icon.png[閒聊] 手把手教你不被桶之新手主購教學
icon.png[分享] Civic Type R 量產版官方照無預警流出
icon.png[售車] Golf 4 2.0 銀色 自排
icon.png[出售] Graco提籃汽座(有底座)2000元誠可議
icon.png[問題] 請問補牙材質掉了還能再補嗎?(台中半年內
icon.png[問題] 44th 單曲 生寫竟然都給重複的啊啊!
icon.png[心得] 華南紅卡/icash 核卡
icon.png[問題] 拔牙矯正這樣正常嗎
icon.png[贈送] 老莫高業 初業 102年版
icon.png[情報] 三大行動支付 本季掀戰火
icon.png[寶寶] 博客來Amos水蠟筆5/1特價五折
icon.pngRe: [心得] 新鮮人一些面試分享
icon.png[心得] 蒼の海賊龍 地獄 麒麟25PT
icon.pngRe: [閒聊] (君の名は。雷慎入) 君名二創漫畫翻譯
icon.pngRe: [閒聊] OGN中場影片:失蹤人口局 (英文字幕)
icon.png[問題] 台灣大哥大4G訊號差
icon.png[出售] [全國]全新千尋侘草LED燈, 水草

請輸入看板名稱,例如:Boy-Girl 或 站內搜尋

TOP