See the code below:
2.toString(); // error 2..toString(); // "2" 2...toString(); // error
I want to know why 2..toString() can work without errors and what happens when it starts?
2..toString()
Can someone explain this?
http://shamansir.imtqy.com/JavaScript-Garden/en/#object
A common misconception is that numeric literals cannot be used as objects. This is because a flaw in the JavaScript parser is trying to parse dot notation on a number as a floating point literal. 2.toString(); // raises SyntaxError There are several workarounds that can be used to create numeric literals as objects. 2..toString(); // the second point is correctly recognized 2 .toString(); // note the space left to the dot (2).toString(); // 2 is evaluated first
A common misconception is that numeric literals cannot be used as objects. This is because a flaw in the JavaScript parser is trying to parse dot notation on a number as a floating point literal.
2.toString(); // raises SyntaxError
There are several workarounds that can be used to create numeric literals as objects.
2..toString(); // the second point is correctly recognized 2 .toString(); // note the space left to the dot (2).toString(); // 2 is evaluated first
Source: https://habr.com/ru/post/954555/More articles:django-rest-framework: __init __ () takes exactly 1 argument (2) - pythonAWS S3 CORS 403 error with OPTIONS request - ajaxlvalue argument for dispatch_semaphore_create? - grand-central-dispatchPHP date string time synchronization - phpDjango error: __init __ () takes exactly 1 argument (2) - djangoSwitching Antlr lexer modes from the parser - antlrHow to request sharepoint list data? - sqlsimulators for testing ONVIF webservice - javaHow can I simulate a POST request using json body in SprayTest? - spraySet height and width of scene and scene in javafx - javaAll Articles