From Imperative vs Declarative Programming and React for People Who Think Things Like React are Weird and Hard.
Go out of the north exit of the parking lot and take a left. Get on I-15 North until you get to the 12th street exit. Take a right off the exit like you’re going to Ikea. Go straight and take a right at the first light. Continue through the next light then take your next left. My house is #298.
My address is 298 West Immutable Alley, Eden, Utah 84310
it’s important to realize that many declarative approaches have some sort of imperative abstraction layer
Knowing the address assumes you have some sort of GPS that knows the imperative steps of how to get to your house.
$("#btn").click(function() {
$(this).toggleClass("highlight")
$(this).text() === 'Add Highlight'
? $(this).text('Remove Highlight')
: $(this).text('Add Highlight')
})
<Btn
onToggleHighlight={this.handleToggleHighlight}
highlight={this.state.highlight}>
{this.state.buttonText}
</Btn>
your code is concerned with what the ultimate goal is — rather than the steps it takes to accomplish that goal
In computer science, declarative programming is a programming paradigm that expresses the logic of a computation without describing its control flow.