Skip to content

Tag: javascript

How to decode nock recorded response

How to ad-hoc decode/uncompress the output produced by the nock recorder so we can see the response as text? I guess we do not understand if the response is gzipped and/or encoded The object works find when we load it into nock, and our tests are behaving as we expect. To see what the API produced, we are hav…

typescript – cloning object

I have a super class that is the parent (Entity) for many subclass (Customer, Product, ProductCategory…) I’m looking to clone dynamically an object that contains different sub objects in Typescript. In example : a Customer that has different Product who has a ProductCategory In order to clone the …

JS Set background image of span

JS: HTML: I was wondering if it would be possible to also set the source of an image in this HTML from my Javascript code. So if I get “Item One” it will display that image in my HTML? Answer You just need to create an array containing the paths to your images such as var images = [“image1.p…

PURE JS get selected option data attribute value returns Null

I have this html: and js but it always alerts null instead of data value Where is the problem guys? Thanks Answer The problem is that you get select element and not selected option element as function argument. And it does not have the data attribute. You have to get the option attribute like so: Notice that …

HTML5 Canvas Javascript how to make smooth brush

Hello i need make smooth brush likes this: I try to create it, i make circle and fill it, but result not successful: Can be seen circles.. this is not smooth like first example my example code: http://codepen.io/anon/pen/NPjwry Answer Try with a smaller globalAlpha and decrease the stepping (so you draw more …