This is Ahmet and I write about software development
You can contact me via the links below
Js Mutation Observer
Whenever a DOM element changes, we can capture it using MutationObserver. Basically you can create a new MutationObserver(callback) instance and then invoke the observe(targetNode, config) function. On a recent project there was a shop plugin I was using in a cart page. Every time user updated quantity, the form element鈥檚 id was changing randomly and I did not know how to access its reference. In a situation like this, you can add a parent element to that <form> and observe that parent element for mutation changes....
Switch Was Not Found in React Router Dom
Imported and tried to use the Switch as in the following; import { Switch, Route } from 'react-router-dom' class App extends React.Component { ... ... render() { return ( .... <Switch> <Route exact ...> <Switch> .... ) } } But it threw the error mentioned in the title. Looks like the project has some breaking changes starting from v6.x So, either you update <Switch /> elements to <Routes />, for details have a look this link, or you can just rollback the react-router-dom version to the latest v5 which currently is v5....
this Keyword in JavaScript
We happen to guess that the this keyword鈥檚 usage is same to the ones in Java or C# or any other OOP language. But it鈥檚 not true. I鈥檝e been following the book series You Don鈥檛 Know JS, and i gotta say using this is not that easy as it looks. What We Normally Assume We think that it refers to the function that it resides in. For example think about this C# code:...
Js, Using Timeout in For Loop
Let鈥檚 say you want to do write numbers from 0 to 10 in a for loop, but you want this to happen after a certain amount of time. Let鈥檚 do this the old way we know Using var keyword I guess that you鈥檇 come up with a solution like this: var counter = 10; for(var i = 0; i < counter; i++){ setTimeout(function timer(){ console.log(i); },1000); } The above code should write the numbers in 1 seconds break, but the ouput is not as we expected, it should write 10 ten times....
Tic Tac Toe Game in Angular
This is a simple Tic Tac Toe game written in Angular 2. You can find the source code here Root Component The project is again generated by angular-cli. I did not include routing in the app. There is only a root component and an HTML & CSS file for it. I also did not touch index.html Logic Let鈥檚 have a look at our component, navigate to src/app/app.component.ts. We have predefined some of our data and also we have this constructor:...