Details
-
AboutContract JavaScript Developer
-
SkillsFront End Architecture, JavaScript Application Design & Development
-
LocationBristol, UK
Joined devRant on 7/30/2017
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
-
Sorry...at a quiz night so no phones allowed. Will reply soon.
-
@okkimus "let the flaming begin" was with regards to the likelyhood of me getting flamed for saying there's no inheritance.
@okkimus in your example, you're not copying the object, you're creating a new empty object and applying obj1's enumerable properties. -
@okkimus it might mean that to you, that doesn't mean that it's correct. In fact, it's just plain wrong. Inheritance has nothing to do with sharing anything. It is about copying.
-
@okkimus misrepresenting my argument by implying I believe you know nothing about programming doesn't make yours any stronger. I've asked you to provide an example, which you still haven't.
Read @ObiSwagKenobi's post below which basically explains in more depth what I was trying to say. -
@ObiSwagKenobi agreed.
-
@okkimus
Why do you care what an MDN page says?
I recruit regularly...but we look for developers who understand (or want to understand) JavaScript 😂
...and I don't flame applicants...ever.
As a side note, this candidate progressed to the second stage. It's fine to say that you don't understand "prototypal inheritance", but to claim to understand the prototype mechanism and still call it "inheritance" is just flat out wrong. -
Okay, let's put this all into perspective.
Inheritance requires the ability to make a copy of an object. Since you cannot do that in JavaScript, you cannot have inheritance.
You can create a new object and link it's __proto__ to another object, which it will delegate behaviour to. However, this is not inheritance.
People using the word "inheritance" because they were brought up on class-based OOP languages and need to perform mental acrobatics to somehow make JavaScript fit into their 'world view', does not mean shit.
Sure, the abstract of the ECMAScript spec uses the word "inheritance" a few times, but read the implementation and it's clear that there is no inheriting of anything going on. It is simply not possible in JavaScript.
Once again, I challenge anybody to provide me with an example of inheritance in JavaScript.
Good luck 🙂 -
@okkimus great, so you read an abstract which uses the word "inheritance". Did you read how to implement that?
-
@wokeRoach @C0D4 please show me an example of inheritance in JavaScript.
-
@wokeRoach no, it's not a volley over semantics. JavaScript DOES NOT support inheritance. Just because you (or MDN) call it inheritance doesn't make it so. As I've already said, read the ECMAScript spec.
-
@wokeRoach @C0D4 there is no concept of "inheritance", classical, prototypal, or whatever, in JavaScript. Behaviour delegation, yes. Inheritance, no. Read the ECMAScript spec 😉
-
@sunfishcc NaN is my favourite number of them all 😁
-
@sunfishcc I think you're missing the point - the code is supposed to be shoddy and unreliable. It's the applicant's task to walk through the problem with me and fix it.
-
@cmrickels they would have been a Junior JavaScript Developer working on a system which essentially processes vast quantities of data. A solid foundational knowledge of _how_ JavaScript works and a good understanding of algorithms is essential.
Not knowing that [0.1, 0.2, 0.3] is an array, well... -
@sunfishcc well the applicant claimed to have 2+ years commercial experience of JavaScript and jQuery.
It's easy to dismiss this question as garbage, but if you can understand and fix it, then you demonstrate knowledge of the call stack, message bus, scope & closure, and the unreliability of numbers due to using IEEE 754 floating point.
...all in 8 lines of code. -
@cmrickels can you post screens?
If you're talking about the 2923, 2943, 2949, as in this pic, that's just the implicit return value of the for loop. -
@cmrickels to see if the person being interviewed understands that by pushing the operation onto the end of the message bus means it's not executed until after the current call stack has completed, meaning it doesn't take place within the current execution context and it has no lexical scope over the i variable at the points it gets incremented, so only has access to it's final value in the global execution context.
...hopefully I articulated that properly.
There is no actual requirement in this use case beyond testing the applicant's knowledge, it could quite easily be making http requests instead of summing the values. -
@samarthagarwal true, it's not. It's fixing 'broken' code.
-
@daintycode no, you still have the floating point precision issue.
-
@YouAreAPIRate the point isn't that the candidate comes up with an answer...I just want them to walk through the initial implementation with me and identify where there might be potential problems, e.g. globally scoped i variable, setTimeout pushing the operation it to the end of the message queue, floating point precision in JS, etc...
-
One solution might be...
sum = numbers.reduce((a, c) => parseFloat((a + c).toFixed(1))); -
@daintycode and yeah...you can't be *sure* about it because it's unpredictable, i.e. sometimes sum == 0.6, sometimes it might not.
-
@daintycode well yeah, that's the point of the question...to refactor it... obviously Array.prototype.reduce is the preferred method.
-
You don't need to remove the setTimeout...you can use block scoping and closure of the i variable using let in the head of the for loop, e.g.
for (let i = 0; i < numbers.length; ++i) { .. }
Even after that, or with the setTimeout removed,
0.1 + 0.2 + 0.3 === 0.60000000000000001
console.log(sum === 6); // false -
Even with the setTimeout removed,
0.1 + 0.2 + 0.3 === 0.60000000000000001 -
Clue 1. JavaScript's Number type uses IEEE 754 floating point precision.
-
@samarthagarwal still returns false.
-
@YouAreAPIRate still returns false though 😉🤔
-
@securiter ...and your solution?
-
@PonySlaystation
const JavaScript = 'JavaScript';
const Java = 'Java';
const Script = 'Script';