given the output is potato? I expect that this output is the result of the assignment, and so five.wtf would be "potato?", not undefined - that one throws me off big time
JavaScript has value types and reference types, value types are... values - things like numbers and strings that are just their value. For example, it wouldn't make sense to change the number 5 in JavaScript, it's conceptually just the value 5.
You can't make the mathematical entity 5 become the mathematical entity 6.
However, you do want stuff like (5).toString() or (5).toFixed(2) because it's useful to have. So for each primitive value type JavaScript has a corrosponding reference type.
@Vogel612 I actually with more languages did strings as value types - it makes them very fast.
So, when you do (5).toString() the engine really does var _ref = new Number(5); _ref.toString(). When you do (5).foo = 5 it does var _ref = new Number(5); _ref.foo = 5.
The original number isn't changed, this is useful behavior. Optimally, the engine would warn you on that (and indeed, linters do) but it can't special-case assignment and property access makes sense.
I have an assignment to encrypt files (+- 1 gb) and speed is an important factor. I am also kinda forced to the C# language since nobody in my group knows C++. The time now recorded for 100 mb is 12 seconds could somebody give me advice if it is possible to improve the speed my encryption functio...
@Hosch250 then you'd have a hard time.. because JS relies on that behaviour. You can't expect to have types define their properties upfront and then write code like: call({foo: "something", bar: "asdf"});
@Mast designing a language is really hard, but I do encourage you to contribute to one of the initiatives to extend JS to be safer or replace it. PureScript and TypeScript are two interesting initiatives.
My teacher referred me to this Stack Community when I showed him my battleships Python code. I created this program with the intent of making it as efficient and readable as possible.
The idea is, you enter an amount of ships, for example 10. It will then place 10 ships on a 10x10 grid (0-9). Yo...
I am getting error related to Invalid Operand to Binary expression.
std::string n;
int i;
std::ifstream myfile("Input.txt");
std::cout<<"The number of elements in the reference string are :";
if (myfile.is_open())
{
while (getline(myfile,n) )
{
std::cout<< n << '\n';
}
for(i...
Here is my Script which takes 50k records from a CSV and does CRUD operation with them. Unfortunately there are a lot of issues with the performance.
CSV fields are: msisdn, resellerid, product
Following are the steps performed:
Read the CSV.
Create Temp table.
Select top 1000 records and mark...
If you admit you have already asked this on CodeReview (correct) and still duplicated post here, what else do you except apart from down-votes? :) — nikhilvartak29 secs ago
Me, CC'ing boss: "So, I haven't made any changes to that little console app in a few weeks.. if it works, can we deploy and close the project?" Boss, to me: "Do not hold your breath...."
"I've just booked tickets: I'll be in London from the 20th until the 27th so I'll be available for those drinks you so graciously offered." Too familiar to send to the VP of Product?
@BenjaminGruenbaum I really, really dislike TypeScript if for nothing else other than they do not gracefully integrate with other packages (yet). If you try and tell it to use a library and it doesn't think it exists, welp, it doesn't exist.
And there are 3 different types of require syntax depending on whether something has typings or not... Babel just lets you use the standard ES6 syntax just fine.
Recently, somebody was given a homework assignment with an exercise specification that left much to desire. Yet, they've tried to make the best out of it and managed to write some code that seems to do something related to the specification; even though it is not clear how this code would be use...
Should I refrain from answering such questions in the future?
You should refrain from answering off-topic questions. This was not an off-topic question.
All on-topic questions should be answered. The quality of the answer could depend on the quality of the question, but not necessarily. Not...
@Vogel612 The other one got downvoted after it was mentioned earlier in the chat. It's a code dump with notice.
The comments in the dump explain something, but it's still not a good review.
Purpose
Implement a solution that returns the values in the Nth row of Pascal's Triangle where N >= 0.
Math
First three rows of Pascal's Triangle:
1
1 1
1 2 1
...
...
These row values can be calculated by the following methodology:
For a given non-negative row index, the first...
I'm in a situation where I need to manage a kind of FIFO process within a SQL procedure. The procedure is called by a multithreaded windows application.
I've created a table which look like this:
+---------------+---------------+----+
| Field | DataType | PK |
+---------------+---...
I wondered if there was a way to DRY (don't repeat yourself) this CSS code or if this is as compact and readable as I can make it?
div#title_bar, div#header {
background: green;
}
#header ul#utility_nav li a {
color: #fff;
}
table.index_table th, table.index_table th.sorted-asc, table.inde...