前端 JS 笔试百题( 十 )

  1. 输出结果是:
$(function () {function fn1( value ) {alert( value );}function fn2( value ) {fn1("A");return false;}var callbacks = $.Callbacks();callbacks.add( fn1 );callbacks.fire( "B" );callbacks.add( fn2 );callbacks.fire( "C" );})
  1. 实现在p元素后添加“Hello World!”,则横线处应使用的方法为( )?
<html><head><script type="text/javascript" src=https://www.isolves.com/it/cxkf/qd/2022-02-28/"/jquery/jquery.js">

This is a paragraph.

This is another paragraph.

  1. 输出结果是:
<div id="box1"><div id="box2">content</div></div><script>const $ = document.querySelector.bind(document);const box1 = $('#box1');const box2 = $('#box2');box1.addEventListener('click', () => {console.log('box1 true');}, true);box1.addEventListener('click', () => {console.log('box1 false');}, false);box2.addEventListener('click', () => {console.log('box2 true');}, true);box2.addEventListener('click', () => {console.log('box2 false');}, false);</script>
  1. 请选择下面代码输出1的次数
var vm = new Vue({el: '#example',data: {message: 'Hello'},computed: {test: function () {console.log(1)return this.message}},created: function (){this.message = 'World'for (var i = 0; i < 5; i++) {console.log(this.test)}}})



推荐阅读