0
Why I get error?
This code is not working: var c, var w = c.width = window.innerWidth, h = c.height = window.innerHeight;
7 Answers
+ 6
Because the declaration for c is ambiguous unless you specify it explicitly as an object with the corresponding attribute like following:-
var c = { width: null, height: null };
Anyway it's still a little bit strange to me to have more than one assignment in a single statement although it's working fine.
+ 5
ĐндŃоК ĐаСаŃОв sorry but that is wrong,if you say
c=document.querySelector("canvas");
c already automatically has width and height properties
so by saying
c={width:null,height:null}
youre changing c value completely making line1 useless.We all make mistakes,youll have to choose between both
+ 4
ive seen your code,after 5 minutes of adjustment,ive repaired it:
https://code.sololearn.com/WF1E2fJ9CWbn/?ref=app
+ 2
because c doesnt have any width or height properties but from no where you just decided c should have one.
var c={
width:5,height:10 }
or perhaps c is an html dom element
like
c=document.querySelector("canvas");
//now try your code
+ 1
thank you gays i'll trying
0
correct code:
var c = document.querySelector("canvas");
var c = { width: null, height: null };
var w = c.width = window.innerWidth,
h = c.height = window.innerHeight;
0
it works!
Thank you for help!đ