JavaScript DELETE statement. Query - javascript

I was just wondering if the DELETE statement is supported by all browsers e.g:
delete myObj;
I just want to make 100% sure if all browsers support this or not?
Also is there any browser or maybe mobile (cell) phones that do not?

Mozilla's Developer Center provides the following information:
Implemented in: JavaScript 1.2, NES3.0
ECMA Version: ECMA-262
So you can check your target browser against this for an idea of whether it's supported at all or not.
Extreme testing of JavaScript delete operator on different browsers seems to suggest that nearly all major browsers do support it, just not equally well. Furthermore, the author provides an extreme test page for you to experiment with your browser online at http://www.trilancer.com/extreme_delete.html
I would also consider reading the following question for more details on how to property use the delete operator:
Deleting Objects in Javascript

To directly answer your question, as far as I am aware, any browser that supports JavaScript supports delete. I checked and it existed in the specification for ECMAScript 1 (released in 1997) so it's been around for a while now.

Related

Is there a modern way of telling what EcmaScript version is installed? [duplicate]

Regarding compatibility between ECMAScript specification and actual implementation;
It is fairly easy to check out the data about browser support for ECMAScript2015 (ES6), but I found it pretty difficult to have an equivalently clear table for all the following ES versions (ES7+).
By the time this question is asked:
Mozilla has some info on their website: it is possible to see that ES7 and ES8 are fully supported, ES9 still has some problems and ES10 is supported on the latest versions.
I can also guess that IE11 never progressed after ES5.
I did not find anything for the other browsers, just some stolen info here and there.
How can I check what the current browser-support level is?
Browser vendors don't implement specific versions, but specific features. Almost every modern browser is still missing features from ES2017-ES2020. Hence there is not and won't be a table where you can see an ES version to browser version mapping.
But that is not a problem because you as a developer do the same. You use features, not versions of ECMAScript. Caniuse is still a great resource to check for support of individual features. If you are not happy with the data presentation on Caniuse, maybe these compatibility tables are better for you. Additionally, you can use polyfills and Babel for transpiling of newer features to older runtimes.
The simple reason is: they don't support it. Everything above ES6 is still in the works. Since ES6 is still being adopted and not all browsers support everything there's no reason for them to aim for ES7. If you want to use >ES7 features I would suggest looking into Babel, since there are ways to use ES7 and above and compile it back to ES5 so that even IE supports it.

How to check JavaScript version in web browser?

I want to check JavaScript Version in my web browser.
Is navigator Object return proper JavaScript version?
navigator.appVersion; /*Is it correct?*/
navigator.appCodeName;
navigator.appName;
Is there any way to detect exact JavaScript Version from Browser console or anything else?
Browsers don't give any real version, because they don't exactly support any one version. They support some (or most) features of some versions.
Any support declared for "JavaScript 1.x" is just a legacy hack for compatibility with Netscape.
Similarly, these navigator fields are useless on purpose. In the past they have been misused to block browsers so much, that the spec now recommends all browsers to lie and say they are Netscape 4.0.
On the web, in general, you should never check version of anything to decide whether it supports the features you need, because it's too easy to make an invalid assumption and break your code in some browser, including future ones you can't test now (e.g. a feature may not be related to the version you assume, or browsers may lie about versions they support in order to work around sites blocking them).
You should use feature detection instead.
You can detect presence of individual JavaScript features by running them and seeing if they work. If the new feature requires a new syntax, you can try running that syntax inside eval. See how it's done on: https://kangax.github.io/compat-table/es6/ (there's a (c) icon with detection code next to features when you expand the list).

Which browsers support Object.observe?

Which browsers, if any, support Object.observe? I'm surprised I'm unable to find any info on this.
(And are you aware about any estimated times of arrival for this feature?)
About Object.observe: "Object.observe allows for the direct observation of changes to ECMAScript objects. It allows an observer to receive a time-ordered sequence of change records which describe the set of changes which took place to the set of observed objects." — see ecmascript.org, the Solution section.)
Edit November 2015: Apparently Object.observe has been cancelled:
http://www.infoq.com/news/2015/11/object-observe-withdrawn
https://esdiscuss.org/topic/an-update-on-object-observe
"I plan to withdraw the Object.observe proposal from TC39"
https://esdiscuss.org/topic/save-object-observe-please-make-weakmap-weakset-observable
"Save Object.observe()! (please)"
You can use kangax's Browser Compatibility Table for Object.observe
It is part of ECMA Script 7 Specifications, it seems. Luckily, at the time of this writing, my current browser, Chrome 33, is the only one which supports it :)
If you like to enable it in Chrome 33,
Visit chrome://flags/
And enable Enable Experimental JavaScript
Polymer is a new and promising framework that intends to implement Web Components, for which Object.observe() is an integral part.
It provides polyfill implementation for "evergreen" browsers; the latest ones available.
Moreover, they track what browser have native support for this feature, so it speeds up their implementation.
This polyfill is available as a separate library on GitHub.
No browsers. If its not true today, it will be true someday, and then this can be the accepted answer.
Chrome 35+ supports Object.observe() Method.
More details here: html5rocks
Update: It's moved to chrome 36 beta.
It used to be present in both Chrome & Opera, but the feature has been removed from both browsers after the standards committee withdrew the proposal for this feature!
Chrome 36+, Opera 30+. My favorite way of answering these questions is http://caniuse.com. It's clear, consice, and has instant search.
Disclaimer: I'm the author of object-observer library.
basarat's answer is definitelly the right one - nowadays no browser supports it.
Most of the polyfills performing 'dirty-checks' - not the best way to achieve observance IMHO.
Better way is to pick up one of the several libraries providing the same functionality utilizing native Proxy capabilities, object-observer being just one of them.

Understanding Javascript versions

I wanted to ask a few questions about javascript:
1.Does each browser implement javascript by itself ? Or is their a common SDK\API or whatever ?
2.If each browser implement by itself, Is the javascript engine bounded to the browser version ?
I mean, can I have 2 different engines for the same browser version ?
3.Is there any standards all javascript engines must follow ? Does this standard define memory
allocation ? (Lets say, How I allocate a javascript string ?)
And last,
What are the names of implementation for each browser ? For example I understood FirFox uses an
implementation called "Rhino", Am I right ?
Thanks alot !
Michael
Yes, they implement JavaScript on they're own.
Yes, it is bound to the browser version. No, you can't have 2 different engines for the same browser version. You can though for different browser versions.
Yes, it is called EcmaScript. Most implementation follow it pretty good.
FireFox does not use Rhino. Mozilla developed it, but the implementation in FireFox is different. All browsers implement single-threaded JavaScript, while Rhino is not single-threaded.
Each browser does implement its own version of JS. Thus, why some browsers outperform others. They specification on what JS should do and how it should be done is based on the ECMAScript specification. The only case I've seen of having multiple engines (or versions of engines) is with IE's web dev toolbar, where you can "roll back" your IE version to test how previous versions react. I've found the JS engine to be pretty faithful when doing browser version tests.
Wiki has a nice write up on the different engines. http://en.wikipedia.org/wiki/JavaScript_engine#Mozilla
JavaScript is standardized through the ECMAScript specification which most browsers will adhere to.
However, not all features are implemented across all browsers and browser versions and some features have their own browser specific quirks.
You can find more details about ECMAScript and the versions browsers implement here:-
http://en.wikipedia.org/wiki/ECMAScript
You will not get two different JavaScript engines offered to you within the same browser (usually).

Why does Google Chrome still support __proto__?

__proto__ is deprecated. Why do big browsers like Google Chrome still use it? Are there any plans to dump it?
One of the hardest thing to do in a language / framework is actually remove a deprecated feature. There is still loads of code in the world which depends on this feature. Removing it will break websites. Chrome has apparently looked at the cost of maintenance vs. the pain /cost of removal and chosen maintenance.
__proto__ is not only deprecated, it was actually never part of the standard. Removing the feature from Chrome would mean that some pages would no longer work in Chrome, and there is no reason to break these pages.
The feature has been added to JavaScript (ECAMScript 5) as the 'getPrototypeOf' function, and new JavaScript programs should use that instead.
A proto pseudo property has been included in §B.3.1 of the draft ECMAScript ed. 6 specification (note that the specification codifies what is already in implementations and what webites may currently rely on).
https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/proto

Categories

Resources