Questions tagged [ecma]

ECMA is a standards organisation

178 questions
5
votes
1 answer

Why did ECMASCRIPT 6 reverse the sides for assignment when destructuring?

Why did ES6 decide that left-side assignment made more sense or was more useful for destructured assignments? Just on first look, it seems to make code more error prone, now that assignment can happen on both sides, depending on situation. let obj…
BrianFreud
  • 5,614
  • 5
  • 28
  • 47
5
votes
2 answers

Browser intl.NumberFormat not displaying currency symbols correctly

I'm attempting to write a currency formatting function using Intl.NumberFormat. It works correctly when I pass it things like USD, or EUR as the currency, but seems to break when I pass it more obscure currency codes like PLN or COL, and instead of…
Gabe O'Leary
  • 1,779
  • 4
  • 21
  • 38
5
votes
3 answers

What does mean?

I have a document created by Excel 2007: ... which contains the following color in a font definition in…
Shelest
  • 620
  • 7
  • 18
4
votes
1 answer

JS string destructuring: rest parameter returning inconsistent data

Consider the following examples An old project: const [x, ...y] = "text"; console.log(x) // "t" console.log(y) // "ext" A new project based on CRA: const [x, ...y] = "text"; console.log(x) // "t" console.log(y) // ["e", "x", "t"] I'm not sure why…
4
votes
2 answers

What does x => x mean when passed to a function in Javascript?

Say I have code like this: function Foo(func) { var a = new SomeClass(func(5)); } var b = new Foo(x=>x); What does the x => x mean in the parameter? x is not defined anywhere else.
BlueTasted
  • 41
  • 2
4
votes
2 answers

Comprehending regex in C++11

I am trying to learn the regular expressions in C++11. Must be doing something wrong since no brackets or escape sequences seem to work. Here is my code: #include #include #include using namespace std; int main() { …
John
  • 500
  • 4
  • 19
3
votes
1 answer

Does Ecma-334 have an incorrect description for next line (C# ECMA Standard)?

In Ecma-334 (C# Language Specification 4th Edition), Annex A. Grammar, Section A.1.1 Line terminators: new-line:: Carriage return character (U+000D) Line feed character (U+000A) Carriage return character (U+000D) followed by line feed…
Amir Saniyan
  • 10,990
  • 18
  • 77
  • 124
3
votes
1 answer

My return value function is failing - Promise related I think

The Problem I am working on a simple login page. From within my view model script, I call another script which handles the calls to my API. In short, I am not getting back the expected data I want, which is simply a token string ( which indicates…
John S.
  • 464
  • 2
  • 11
3
votes
1 answer

'includes' does not exists on type 'string[]' in TypeScript

From this question and the accepted answer, I know that there is an methode to check if an array includes an object in JavaScript by using this line of code: > ['joe', 'jane', 'mary'].includes('jane'); true However if I use the same code in…
H. Pauwelyn
  • 11,346
  • 26
  • 71
  • 115
3
votes
2 answers

Decorators for functions

As I see, decorators usually can be used with classes and methods inside classes. Is there a way to use decorators with regular functions like in code below: @myDecorator() function someFunction() { // do something } someFunction(); // running…
Bogdan Surai
  • 848
  • 10
  • 15
3
votes
1 answer

Can somebody explain the use of statement values Javascript ECMAScript?

I am new to Javascript and have noticed that statements have values: > x = 1 <- 1 > if (false) { x=1; } else { x=2 }; <- 2 Could somebody explain why statements have values what they are used for in real applications, since functions need…
er0
  • 1,445
  • 1
  • 11
  • 27
3
votes
1 answer

Why are there differences between the node REPL and node script running when evaluating these expressions

Why is there a difference between how Node REPL and the Node engine operating on a script interpret the following expression: {...a}? I'm running node v8.3.0 (discovered by running node -v) and have found an odd difference between the command line…
3
votes
4 answers

javascript using reduce function

I have the below array ["0,5,p1", "24,29,p2", "78,83,p2", "78,83,p3", "162,167,p2" ] i want the output as ["5,p1","10,p2","5,p3"] , so p1..3 are video files paying time with start and end time . 0,5 mean p1 profile played for 5 sec and so…
Mohit H
  • 773
  • 2
  • 10
  • 19
3
votes
1 answer

How do I write a conditional xpath select for specific nodes?

So I have a userscript added on chrome, autopagerizer. currently I'm using //div[@class=\'entry-content\']/p[contains(.,\'chapter\') or contains(.,\'Chapter\') or preceding-sibling::p[contains(.,\'Chapter\')] and…
skaviouz
  • 45
  • 6
3
votes
2 answers

What is the reason for making Object.freeze() to fail silently?

Why is that Object.freeze(obj) is made to fail silently when obj is mutated? Wouldn't it be more logical to throw than error when an immutable object is mutated? Then, it would be to the user's discretion if he wants to wrap a try catch around his…
sgsvnk
  • 1,991
  • 2
  • 17
  • 45
1
2
3
11 12