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?

5

1 Answer 1

-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'

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.