Skip to content

Tag: javascript

Term.js – page scrolls down to the section with the terminal

This is probably a silly question – I’m using term.js to simulate a linux terminal. Everything works fine. The only issue I am having is – the page where I have embedded it is pretty long and this terminal is somewhere at the bottom – but as soon as the page loads – it automatica…

Object destructuring without var, let or const

Why does object destructuring throw an error if there is no var keyword in front of it? throws SyntaxError: expected expression, got ‘=’ The following three examples work without problems Bonus question: Why do we not need a var for array destructuring? I ran into the problem doing something like …

Regex for matching HashTags in any language

I have a field in my application where users can enter a hashtag. I want to validate their entry and make sure they enter what would be a proper HashTag. It can be in any language and it should NOT precede with the # sign. I am writing in JavaScript. So the following are GOOD examples: Abcde45454_fgfgfg (good…

how to render multiple children without JSX

How to write this without using JSX? This comes from the react.js tutorial: http://facebook.github.io/react/docs/tutorial.html I know I can do the following: But this only adds one element. How can I add more next to one another. Answer You can use the online Babel REPL (https://babeljs.io/repl/) as a quick w…

jshint Error: Cannot find module ‘underscore’

My grunt task seems to be running perfectly fine, but every time I run it I’m getting this error: Is there any way to find out why this is happening? I can see the /grunt-contrib-jshint directory is in the /node_modules directory. Is there any reason it can’t find the underscore module? I’ve…

Parse.com relations count

I want to query object from Parse DB through javascript, that has only 1 of some specific relation object. How can this criteria be achieved? So I tried something like this, the equalTo() acts as a “contains” and it’s not what I’m looking for, my code so far, which doesn’t work: …

react.js: removing a component

I’m fairly new at react.js, so any help is greatly appreciated. I have this: https://jsfiddle.net/rzjyhf91/ Wherein I have made 2 components: an image and a button. The goal is to remove the image with a click of the button, I use unmountComponentAtNode for that, but it does not work: How can I remove a…