
Inline adoc files when they are included exactly once. Also fix language tags because this inlining gives us better information on what language the code is written in.
67 lines
1.4 KiB
Plaintext
67 lines
1.4 KiB
Plaintext
== Why is this an issue?
|
|
|
|
The semantics of the ``++delete++`` operator are a bit tricky, and it can only be reliably used to remove properties from objects. Pass anything else to it, and you may or may not get the desired result.
|
|
|
|
|
|
=== Noncompliant code example
|
|
|
|
[source,javascript]
|
|
----
|
|
var x = 1;
|
|
delete x; // Noncompliant
|
|
|
|
function foo(){
|
|
..
|
|
}
|
|
|
|
delete foo; // Noncompliant
|
|
----
|
|
|
|
|
|
=== Compliant solution
|
|
|
|
[source,javascript]
|
|
----
|
|
var obj = {
|
|
x:1,
|
|
foo: function(){
|
|
...
|
|
}
|
|
};
|
|
delete obj.x;
|
|
delete obj.foo;
|
|
----
|
|
|
|
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
=== Message
|
|
|
|
Remove this "delete" operator or pass an object property to it.
|
|
|
|
|
|
=== Highlighting
|
|
|
|
* Primary: entire ``++delete++`` expression
|
|
|
|
|
|
'''
|
|
== Comments And Links
|
|
(visible only on this page)
|
|
|
|
=== on 4 Jun 2015, 12:13:03 Elena Vilchik wrote:
|
|
\[~ann.campbell.2] Assign to you for validation and completion (labels, SQALE). CC [~linda.martin]
|
|
|
|
=== on 4 Jun 2015, 14:10:16 Ann Campbell wrote:
|
|
\[~elena.vilchik] I've updated the description based on \https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/delete, which shows that _sometimes_ ``++delete++`` does work on things that might be thought of as variables (even though they're really properties of the global object.)
|
|
|
|
|
|
Let me know if it's not okay
|
|
|
|
endif::env-github,rspecator-view[]
|