0
Need help in typeof Operator in Javascript
I make a program in JS which will print the type of string but I get an error https://code.sololearn.com/W1GrlUM7B9vq/?ref=app
1 Answer
+ 3
window.onload=function(){
Js code goes here
}
Js script gets loaded before html here in sololearn ,so you are accessing a element which doesn't exit yet so hence the innerHTML returns null ,to prevent it windows.onload function let the html Dom get loaded first and then script is executed