9
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

第6回つぶやき勉強会 ~JSと仲良くなろうの会~

9
Last updated at Posted at 2016-11-28
Page 1 of 10

Q1

jQueryの $ は次のうちどれですか?

  • a. 関数
  • b. オブジェクト
  • c. それ以外

Q2

コンソールで $.hoge をすると undefined になります。

$.hoge = "piyo";

上記以外の方法で、$.hoge が piyo となるようにせよ。


Q3

// 任意の要素 any に対して、(any は div, span...など)
$('any').hoge // => piyo

上を実現せよ。
(ヒント: $('div').__proto__ )


Q4

class Person
  def initialize(name)
    @name = name
  end
  def greet
    "My name is #{@name}"
  end
end

person = Person.new("Shiraki")
person.greet # => "My name is Shiraki"

上と同じようなことを JavaScript でやってみてください。


Q5

ここにオブジェクト obj があります。
obj が、jQueryオブジェクトか否かを判別する方法を示せ。
( jQuery 自体は読み込まれているとする。 )


Q6

var piyo = 9;
hoge = function(){
  console.log(piyo);
  var piyo = 1;
}

hoge() // => これはなんですか?

答え

  1. 関数, オブジェクト
  2. $.extend({hoge: "piyo"})
  3. $.fn.extend({hoge: "piyo"})
  4. 別紙
  5. obj instanceof jQuery
  6. undefined
  • 2の別 $["hoge"] = "piyo";

4の答え

function Person(name){
  this.name = name
  this.greet = function(){ 
                 return "My name is " + this.name
               }
}
person = new Person("Shiraki");
person.greet(); // => "My name is Shiraki"

以上。ありがとうございました。 :earth_africa:

9
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?