score:1
Accepted answer
seems that keyword this
is ambigous, as soon as newuserdocs
is defined as variable you can access is without this.
portion as soon as context for this
is unclear in your example:
if(this.newuserdocs.username === "test"){
console.log('the username is good');
}
upd: js is case sensitive. your variable is called newuserdocs
(lower-case u) and then your access it by newuserdocs
(upper-case u). try newuserdocs.username
score:1
i run this, it works perfect. you missed:
- you have to approach the variable without use
this.
. the spelling of the const.
const newuserdocs = {username:"test", name:"testname"}; console.log(newuserdocs); if(newuserdocs.username === "test"){ console.log('the username is good'); }
i hope it helps you.
Source: stackoverflow.com
Related Query
- reactjs, comparison using array from document
- Get last 7 days' dates as an array from today's date using momentJs, ReactJs
- Returning values from an array in reactjs without using this.state
- Reactjs - add/remove item from array and store using checkbox
- ReactJS Photo Gallery using an array of urls from Express database?
- How to display markers from array in reactjs using leaflet charts
- How to remove one item from an array using filter() in ReactJS - function not working properly
- ReactJS remove one td from array when using array.map
- ReactJS - How to render single object from an array using id?
- How to remove an array from an object using reactjs
- Using component key to delete element from array Reactjs
- How to filter data from an array and display it accordingly using ReactJs
- Post multiple Request to REST API django from Array using Axios in Reactjs
- Creating li tags from an array using ReactJS
- how to fetch the data from the response like array format using reactjs
- forEach not working in ReactJs while using data from array
- Removing object from array using hooks (useState)
- ReactJS not fetching data from server when using 'url' attribute
- Using an input field with onBlur and a value from state blocks input in Reactjs JSX?
- How to get byte array from a file in reactJS
- How to delete object from array using object property - React
- Reactjs - Setting State from props using setState in child component
- Send IP address from frontend using ReactJS to server NodeJS
- What's the advantage of using $splice (from immutability-helper) over filter to remove an item from an array in React?
- How to play one video from array at a time in ReactJS & AG Grid
- how to remove duplicate objects from an array in reactjs
- Multiple hover popovers from an array using Material-UI opens only one popover
- Create nested JSX list items from multi-level nested array of objects reactjs
- create a mobile app from my web site using reactjs (not native)
- How to pass data from one component to another while using API in reactjs
More Query from same tag
- consistently return objects instead of promises useEffect()
- Update array of objects depending on other array of object value
- Passing React Router Link "to" parameter as props
- Why can't I use a union type with redux connect?
- My React app page scroll to Top is ugly. Is there a scroll method that doesn't scroll?
- componentDidMount called before real DOM is available
- Avoid re-rendering of a component because of a custom hook which is used by other components?
- Error : Text strings must be rendered within a <Text> component
- How to Update Typescript React Redux State With One or More Reducer State Values
- how to install the new version of react app 5.0.0
- How can I validate 'double' type within From Validation
- How to stop react component from infinite re-render
- How to call a state from a component to a page?
- Access imported module in top level scope of file with 'circular' dependency?
- ReactJS - Updating the state causes lag
- Material UI: Styles flicker in and disappear
- How to hide container div title when hovering inner elements?
- How to use Material UI's 'useMediaQuery' with a class component
- error saying:- Idling, State changed from up to starting, Stopping all processes with SIGTERM, Process exited with status 143
- Call and store data from a API in React Reducer
- React-select is not send in the request payload
- How to avoid failed to acquire camera feed
- Cannot find module issue with imports-loader when testing with Jest
- Calling a component based on conditions
- Pass an argument to anonymous function
- How to add a dynamic class to body tag in Gatsby.js?
- How to avoid Flow typing error with empty array?
- react-bootstrap modal override class not working
- How can I change image src?
- React/ TYpescript open new page and pass Data