Skip to content
Advertisement

Tag: javascript

Why is getServerSideProps data being changed?

I’ll fetch data from an API, When I pass my getServerSideProps data to index.js, the prop array is in order by rank. [1,2,3..etc]. ex: data When I alter that data into a different variable, for example: console log shows data is now sorted by price too, when I only wanted topPrice to be sorted, why? Answer sort function alters your

React useState, setState and {state} in return

I come across the rendering issue with React State. The problem is that {state} in return get value one beat late. But the console log in handleChange shows right value. If the previous value of state is 9, current value of state value is 10 then the console.log({state}) in handleChange shows 10 and the <span>{state}<span> in return shows 9. It

Adding new array in object

I’m working on an application that involves a somewhat complex user registration. Something similar to this. When a user adds a new address to a person he is registering, he should add a new address to the person and keep the previous data. But it creates a new data array with just the address data, outside of the specified person.

JavaScript converting the string “constructor” to [Function: Object]

I’m building a parser for a simple interpreter in JavaScript. I have a preprocessor method that removes specific tokens from an input list of tokens produced by the tokenizer: Each token is an object like this, with both type and value being strings: Somewhere in this function, when tokens[i].value == ‘constructor’, said value is being converted to the actual JS

Why is my decryption function not working?

I created a function to encrypt and decrypt messages. the encrypting works fine. but when I try to log encrypted Hello World! it just logs H. Fixed it, i edited the encoding system to place a – between chars and the decoding system to just split the message at – and check if the element starts with c n or

Advertisement