1

In the my script document is an object and querySelector is a method. But what is innerHTML? Is it a property?

document.querySelector('#heading').innerHTML = "Hello world";

If it is a property, how i can write my own properties and methods like that?

James Z
  • 12,209
  • 10
  • 24
  • 44

1 Answers1

-1

the answer is yes. these are predefined objects, methods, and properties.

to create an object: var o = {};

to create a function: var f = function(){};;

since JS is a dynamic programming language you can always add functions and properties at any time.

in JS functions and objects are the same. so to both adding another function: f.add or o.add = function(a, b){return a+b};

and to both adding a property f.name or o.name = 'I'm Batman'

bresleveloper
  • 5,940
  • 3
  • 33
  • 47