Skip to content

Tag: javascript

Validating object structure in vue.js

I’m currently building a component in vue.js and I have a bit of a problem. You see, there’s a lot of parameters you can give to my component, so for the sake of clarity, I decided to go with the approach below: Basically, I define an object containing the necessary parameters and I give that to m…

convert hex to binary in javascript

I need to convert hex into binary using javascript. example: 21 23 00 6A D0 0F 69 4C E1 20 should result in: ‭0010000100100011000000000110101011010000000011110110100101001100‬ Does anyone know of a javascript library I might use to accomplish this? Harriet Answer You can create a function converting a hex num…

How to properly use Object.setPrototypeOf()

So I’ve been getting up to speed on some of the newer features of JavaScript and have been reading about Object.setPrototypeOf(). I ran across this bit of code from MDN which deals with inheriting from regular objects. But I’m confused at how they use Object.setPrototypeOf() here. I expected them …

Why does this JSX expression produce an odd result?

I was playing around with JSX when I found this oddity. Using the following JSX: Will produce the correct result: But I wanted to add double quotes around the quote, so I tried: Which, to my surprise, gave the correct output: I was expecting an output similar to this since it was a string literal: Why doesn&#…