0

JavaScript .getContext(“2d”)

I ask why the .getContext(“2d”) doesn’t work in the code editor but it works in the console? Example: var canvas = document.getElementById(“mycanvas”).getContext(“2d”); The error: cannot get context of null It works sometimes but at other times it doesn’t. Please answer

21st Dec 2017, 6:10 PM
Kenzoid
Kenzoid - avatar
1 Respuesta
0
The playground tries to emulate a browser environment, but also note that it provides for other programming languages. If all assets from a Chrome console were ported over, the Sololearn app would increase in size. The service may be offered via internet, but everything about developer consoles is properietary and has little documentation. So, undesired and displeasing effects make themselves known. If in doubt, check your IDs... NameErrors are common.
21st Dec 2017, 7:00 PM
ghostwalker13
ghostwalker13 - avatar