If you evaluate {} + 1 , you get 1 , but if you assign the same expression to a variable, say x = {} + 1 , the variable will contain the string "[object Object]1" .
{} + 1
1
x = {} + 1
"[object Object]1"
Why does assignment alter the semantics of the expression on the right side? Should the right-side expression be โcontext-freeโ?
interpreted as a block of code followed by +1 , which evaluates to 1 . From:
+1
evaluated as new Object() plus 1
new Object()
If you changed the original statement to:
new Object() + 1
As a result, you will see "[object Object]1" .
Source: https://habr.com/ru/post/955614/More articles:Show Modal Window in Xamarin - c #Looking for specific row data in all database tables? Without creating a procedure or table - sqlThe correct way to clean up a Python service is atexit, signal, try / finally - pythonConvert Rails 4 has_many from the condition with proc, where - ruby-on-rails-4Why does the python class that inherits the "object" call "super" in the __init__ method? - pythonfine uploader add prefix to file name on s3 - fine-uploaderWhy doesn't the Node REPL give the same results as the Wat video or my browser console? - javascript"error: 19 - Physical connection is not used" when I change my Staging and Production deployments on Windows Azure - tfsGeneral Query Method - genericsHow to delete a previous account in heroku - herokuAll Articles